package org.acghub.mtdb.core;

import org.acghub.mtdb.common.exception.LifecycleException;

/**
 * @author zhouhe
 */
public abstract class AbstractTableCache<K, V> implements TableCache<K, V> {

    protected Table<K, V> table;
    protected int capacity;

    @Override
    public void init(Table<K, V> table) throws LifecycleException {
        this.table = table;
        this.capacity = table.meta().getCacheCapacity();
    }

    @Override
    public int capacity() {
        return capacity;
    }

    public Table<K, V> table() {
        return table;
    }

    @Override
    public void close() throws LifecycleException {
        table = null;
    }
}
